<?php

include_once 'database.php';
include_once 'common.php';

function rootBreadCrumb(){
	
	return "<a href=\"home.php\">Home</a>";
}

function projectBreadCrumb($intProjectId){
	if($intProjectId != 0){
		$dbResult = mysql_query("SELECT project_name FROM project WHERE project_id=$intProjectId") 
	or die("Problem reading table: " . mysql_error());
		$row = mysql_fetch_array($dbResult);
		$strProjectName = $row['project_name'];
		return rootBreadCrumb() . " &gt;&gt; " . "<a href=\"projects.php?id=$intProjectId\">$strProjectName</a>";
	}
	return rootBreadCrumb();
}

function iterationBreadCrumb($intIterationId){
	if($intIterationId != 0){
		$dbResult = mysql_query("SELECT start_date, end_date, project_id FROM iteration WHERE iteration_id=$intIterationId") 
	or die("Problem reading table: " . mysql_error());
		$row = mysql_fetch_array($dbResult);
		$intProjectId = $row['project_id'];
		$strStartDate = date(JQUERY_DATEFORMAT, strtotime($row['start_date']));
		$strEndDate = date(JQUERY_DATEFORMAT, strtotime($row['end_date']));
		return projectBreadCrumb($intProjectId) . " &gt;&gt; " . "<a href=\"iterations.php?id=$intIterationId\">$strStartDate - $strEndDate</a>";
	}
	return rootBreadCrumb();
}

function storyBreadCrumb($intStoryId){
	if($intStoryId != 0){
		$dbResult = mysql_query("SELECT iteration_id, story_name FROM story WHERE story_id=$intStoryId") 
	or die("Problem reading table: " . mysql_error());
		$row = mysql_fetch_array($dbResult);
		$intIterationId = $row['iteration_id'];
		$strStoryName = $row['story_name'];
		return iterationBreadCrumb($intIterationId) . " &gt;&gt; " . "<a href=\"story.php?id=$intStoryId\">$strStoryName</a>";
	}
	return rootBreadCrumb();
}